package org.blade.personal.dao.sys.impl;

import java.util.List;

import javax.persistence.Query;

import org.blade.personal.dao.base.BaseDao2;
import org.blade.personal.dao.base.EntityMapper;
import org.blade.personal.dao.sys.RoleDao;
import org.blade.personal.mode.sys.SystemRole;
import org.springframework.stereotype.Repository;

@Repository("roleDao")
public class RoleDaoImpl extends BaseDao2<SystemRole,Long> implements RoleDao {

	@Override
	public void add(final SystemRole role) {
		super.add(role);
	}

	@Override
	public void update(final SystemRole role) {
		super.update(role);
	}

	@Override
	public int delete(final Long id) {
		
		Query query = super.entityManager
				.createNativeQuery("delete from Role where id in (?)");
		return query.setParameter(1, id).executeUpdate();
	}

	@Override
	public int deleteByIds(String ids) {
		return super.entityManager
				.createQuery(" delete from Role where id in (?) ")
				.setParameter(1, ids).executeUpdate();
	}

	@Override
	public SystemRole queryOne(final Long id) {
		
		return super.getById(id);
		
	}

	@Override
	public List<SystemRole> fetchAllRoles() {
		return this.findList();
	}


}
